

dialog.frame.prototype.getChildByName = function(checkName){
	for(var n=0;n < this.child.length;n++){
		if(this.child[n].name == checkName){
			return this.child[n];
			}
		var founded = this.child[n].getChildByName(checkName);
		if(founded){
			return founded;
			}
		}
	}
	
	
//对话框的打开和关闭的函数--------------------------------------------------------------
dialog.moveDialogTo = function(thisDialog,x,y,tStep){
	if(thisDialog.moveTime){
		clearInterval(frameMoveTime[thisDialog.moveTimeNum]);
		frameMoveTime[thisDialog.moveTimeNum] = null;
		thisDialog.moveTime = null;
		thisDialog.moveTimeNum = null;
		}
	var availTimeNum;
	var newArray = true;
	for(var n=0;n < frameMoveTime.length;n++){
		if(!frameMoveTime[n]){
			availTimeNum = n;
			newArray = false;
			break;
			}
		}
	if(newArray){
		availTimeNum = frameMoveTime.length;
		}
	var n = 0;
	var tStep = !tStep ? 15 : tStep;
	var before = [thisDialog.x,thisDialog.y];
	var xL = x-thisDialog.x;
	var yL = y-thisDialog.y;
	frameMoveTime[availTimeNum] = setInterval(function(){dialog._moveSteps(availTimeNum,
																		   thisDialog,before,
																		   xL,yL,n,tStep);n++;},10);
	//存储这个对话框对应的时间函数，并存储其对应上的数组的序号。这两个必须同时生成和删除。
	thisDialog.moveTime = frameMoveTime[availTimeNum];
	thisDialog.moveTimeNum = availTimeNum;
	}
	
dialog._moveSteps = function(availTimeNum,thisDialog,before,xL,yL,n,tStep){
	var afterX = before[0]+xL*Math.sin(n*PI/2/tStep);
	thisDialog.x = afterX;
	var afterY = before[1]+yL*Math.sin(n*PI/2/tStep);
	thisDialog.y = afterY;
	thisDialog.transform.identity();
	thisDialog.transform.translate(afterX,afterY,thisDialog.z);
	if (n>=tStep){
		clearInterval(frameMoveTime[availTimeNum]);
		frameMoveTime[availTimeNum] = null;
		thisDialog.moveTime = null;
		thisDialog.moveTimeNum = null;
		}
	}
	
/*
dialog.closeDialogTo = function(thisDialog,x,y,tStep){
	if(!frameMoveTime){
		var n = 0;
		var tStep = !tStep ? 15 : tStep;
		var before = [thisDialog.x,thisDialog.y];
		var xL = x-thisDialog.x;
		var yL = y-thisDialog.y;
		frameMoveTime = setInterval(function(){dialog._closeSteps(thisDialog,before,xL,yL,n,tStep);n++;},10);
		}
	}
	
dialog._closeSteps = function(thisDialog,before,xL,yL,n,tStep){
	var afterX = before[0]+xL*Math.sin(n*PI/2/tStep);
	thisDialog.x = afterX;
	var afterY = before[1]+yL*Math.sin(n*PI/2/tStep);
	thisDialog.y = afterY;
	thisDialog.transform.identity();
	thisDialog.transform.translate(afterX,afterY,thisDialog.z);
	if (n>=tStep){
		clearInterval(frameMoveTime);
		frameMoveTime = null;
		//dialog.removeDialog(thisDialog);
		}
	}
*/	
	
dialog.removeDialog = function(thatDialog){
	if(thatDialog.child[0]){
		for(var n=0;n < thatDialog.child.length;n++){
			dialog.removeDialog(thatDialog.child[n]);
			}
		}
	thatDialog.transform.parent = null;
	thatDialog.scaleTransform.parent = null;
	cubePack.removeObject(thatDialog.transform);
	cubePack.removeObject(thatDialog.scaleTransform);
		if(thatDialog.bgImageTexture){
			cubePack.removeObject(thatDialog.bgImageMoveTransform);
			cubePack.removeObject(thatDialog.bgImageTransform);
			cubePack.removeObject(thatDialog.bgImageSampler);
			}
		if(thatDialog.bgColorTexture){
			cubePack.removeObject(thatDialog.bgImageMoveTransform);
			cubePack.removeObject(thatDialog.bgImageTransform);
			cubePack.removeObject(thatDialog.bgColorTexture);
			cubePack.removeObject(thatDialog.bgImageCanvas);
			cubePack.removeObject(thatDialog.bgImageSampler);
			}
		if(thatDialog.textTexture){
			cubePack.removeObject(thatDialog.textMoveTransform);
			cubePack.removeObject(thatDialog.textTransform);
			cubePack.removeObject(thatDialog.textPaint);
			cubePack.removeObject(thatDialog.textTexture);
			cubePack.removeObject(thatDialog.textCanvas);
			cubePack.removeObject(thatDialog.textSampler);
			}
	thatDialog = null;
}

dialog.alphaShow = function(thisDialog,alphaBefore,alphaAfter,tStep,afterAction){
	var afterAction = !afterAction ? function(){} : afterAction;
	
	if(thisDialog.alphaTime){
		clearInterval(frameAlphaTime[thisDialog.alphaTimeNum]);
		frameAlphaTime[thisDialog.alphaTimeNum] = null;
		thisDialog.alphaTime = null;
		thisDialog.alphaTimeNum = null;
		}
	var availTimeNum;
	var newArray = true;
	for(var n=0;n < frameAlphaTime.length;n++){
		if(!frameAlphaTime[n]){
			availTimeNum = n;
			newArray = false;
			break;
			}
		}
	if(newArray){
		availTimeNum = frameAlphaTime.length;
		}
		var n = 0;
		var tStep = !tStep ? 20 : tStep;
		var alpha = !alpha ? 1 : alpha;
		var alphaL = alphaAfter-alphaBefore;
		frameAlphaTime[availTimeNum] = setInterval(function(){
										dialog._alphaShowSteps(availTimeNum,thisDialog,alphaBefore,
															   alphaL,n,tStep,afterAction);
										n++;
										},
										10);
		thisDialog.alphaTime = frameAlphaTime[availTimeNum];
		thisDialog.alphaTimeNum = availTimeNum;
	}
	
dialog._alphaShowSteps = function(availTimeNum,thisDialog,alphaBefore,alphaL,n,tStep,afterAction){
	var alphaNow = alphaBefore+alphaL*Math.sin(n*PI/2/tStep); 
	thisDialog.changeFrameAlpha([alphaNow]);
	if (n>=tStep){
		clearInterval(frameAlphaTime[availTimeNum]);
		frameAlphaTime[availTimeNum] = null;
		thisDialog.alphaTime = null;
		thisDialog.alphaTimeNum = null;
		afterAction();
		}
	}
	
dialog.create_ATips = function(dialogCreator,content,width){
	var tipsText = dialogCreator.createASection("tipsText",content,width-70);
	
	//var oriX = cubeClient.width-width;
	//var oriY = cubeClient.height-90;
	
	var certainButton = dialogCreator.createAButton("closeButton",["关闭"],[],[,75,20],
													textures["button_closeX_white"],textures["button_closeX_red"]);
	var nolongerButton = dialogCreator.createAButton("nolongerButton",["不再提示",15],[],[,75,20],
													textures["button_white"],textures["button_red"]);
	var tipsArray = [0,0,"tips",[],[textures["tips_bg"]],[],[],
						[70,10,tipsText],
						[80,45,certainButton],
						[165,45,nolongerButton]
					 ];
	var tips = dialogCreator.converArrayToDialog(tipsArray);
	tips.changeFrameAlpha([0]);
	tips.showBy = function(text,width,second){
		//重新开始一次计时
		clearInterval(this.displayTime);
		this.displayTime = null;
		var nSecond = !second ? 20 : second;
		var nCount = 0;
		this.displayTime = setInterval(function(){tips._timeCounter(nSecond,nCount);nCount++},1000);
		
		if(!mouseButton["nolongerTips"]){
			var width = !width ? 600 : width;
			if(!this.diaplaying){
				this.moveTo([cubeClient.width-width,20]);
				var tipsText = this.getChildByName("tipsText")
				tipsText.changeText([text,,,,,,width-80]);
				tipsText.changeFrameAlpha([0]);
				dialog.alphaShow(this,0,1);
				//以下两个应该同时使用
				this.addNewActiveNow();
				this.diaplaying = true;
				}
			else{
				var thisDialog = this;
				dialog.alphaShow(this,1,0,10,function(){
													thisDialog.moveTo([cubeClient.width-width,20]);
													var tipsText = thisDialog.getChildByName("tipsText")
													tipsText.changeText([text,,,,,,width-80]);
													tipsText.changeFrameAlpha([0]);
													dialog.alphaShow(thisDialog,0,1);
													});

				
				
				}
			}
		}
		
	
	tips.hidden = function(){
		if(this.diaplaying){
			clearInterval(this.displayTime);
			dialog.alphaShow(this,1,0);
			this.delActiveNow();
			this.diaplaying = false;
			this.displayTime = null;
			}
		}
		
	tips.flashDataBy = function(trueDialog){
		switch (trueDialog.name){
		case "closeButton":
			//确定按钮按下后的动作
			clearInterval(this.displayTime);
			dialog.alphaShow(this,1,0);
			this.delActiveNow();
			this.diaplaying = false;
			this.displayTime = null;
			break;
		case "nolongerButton":
			//确定按钮按下后的动作
			mouseButton["nolongerTips"] = true;
			clearInterval(this.displayTime);
			dialog.alphaShow(this,1,0);
			this.delActiveNow();
			this.diaplaying = false;
			this.displayTime = null;
			break;
			}
		}
	tips._timeCounter = function(tStep,tNow){
		if(tStep < tNow){
			clearInterval(this.displayTime);
			dialog.alphaShow(this,1,0);
			this.delActiveNow();
			this.diaplaying = false;
			this.displayTime = null;
			}
		}
	return tips;
	}
	

	
dialog.basicCreator = function(){
	//这个函数可以创建一个对”话框创造器“对象，可以有一些默认创造属性，比如aplha=0.5，这样创建出来的对话框会都是
	//半透明显示（需要稍微改动函数，这个功能没有完成）
	}
	
	
dialog.basicCreator.prototype.createASection = function(name,content,width){
	var section_text = [];
	section_text[0] = content;
	section_text[6] = width;
	
	var section = new dialog.frame(name,section_text,[],[],[]);
	
	return section;
	}
	
	
dialog.basicCreator.prototype.converArrayToDialog = function(dialogArray,translate){
	//话框创造器的一个功能函数：把一个数组转换成对话框组合
	var newDialog;
	var translated = translate;//保存是否最顶层偏移过。只对最顶层偏移一次。
		if(dialogArray[7]){
			if(typeof dialogArray[2] == "string"){
				newDialog = new dialog.frame( dialogArray[2],
									dialogArray[3],
									dialogArray[4],
									dialogArray[5],
									dialogArray[6]
											   );
				}
				else{
					newDialog = dialogArray[2];
					}
			if(!translated){
				newDialog.moveTo([dialogArray[0],dialogArray[1]]);
				newDialog.x = dialogArray[0];
				newDialog.y = dialogArray[1];
				}
			translated = true;
			for(var n=7;n < dialogArray.length;n++){
					var childDialog;
					var numLength = dialogArray.length;
					childDialog = this.converArrayToDialog(dialogArray[n],translated);
					newDialog.addFrame([childDialog,dialogArray[n][0],dialogArray[n][1]]);
				}
			return newDialog;
			}
			else{
			if(typeof dialogArray[2] == "string"){
				newDialog = new dialog.frame( dialogArray[2],
									dialogArray[3],
									dialogArray[4],
									dialogArray[5],
									dialogArray[6]
											   );
				}
				else{
					newDialog = dialogArray[2];
					}
				if(!translated){
					newDialog.moveTo([dialogArray[0],dialogArray[1]]);
					newDialog.x = dialogArray[0];
					newDialog.y = dialogArray[1];
					}
				translated = true;
				return newDialog;
				}
	}
	
dialog.basicCreator.prototype.createAButton = function(name,buttonText,bgImage,bgColor,
													   textureUncross,textureCross){
	//创造器对象的一个构造函数：创建一个基本按钮，单击这个按钮会响应到它的最上层并告诉最上层自己被按下。
	var text = buttonText;
	text[1] = text[1] ?  text[1] : "center";
	text[2] = text[2] ?  text[2] : "middle";
	
	var activation = [];
	activation["activeDown"] = function(){
			var topParent = dialog.findTheTopParent(this);
			topParent.flashDataBy(this);
			if(mouseCursorStatus && mouseAmong == 0){  
				mouseCursor = mouseCursorStatus;
				mouseCursorStatus = null;
				}
			
		}
	activation["activeLeave"] = function(){
			if(mouseCursorStatus && mouseAmong == 0){  
				mouseCursor = mouseCursorStatus;
				mouseCursorStatus = null;
				}
		if(mouseButton[name+"_cross"]){
			this.getChildByName(name+"show").changeBgImageTexture([textureUncross]);
			mouseButton[name+"_cross"] = false;
			}
		}
	activation["activeOver"] = function(){
		
		if(!mouseCursorStatus){
			mouseAmong = 0;
			mouseCursorStatus = mouseCursor; 
			mouseCursor = "POINTER";
			}
		
		if(!mouseButton[name+"_cross"]){
			this.getChildByName(name+"show").changeBgImageTexture([textureCross]);
			mouseButton[name+"_cross"] = true;
			}
		}
		
	var buttonArray = [0,0,name,text,bgImage,bgColor,activation,
						   [0,0,name+"show",[],[textureUncross],[],[]]
						   ];
	var button = this.converArrayToDialog(buttonArray);
	
	return button;
	}

	
dialog.basicCreator.prototype.createAColorPlan = function(name,defultColor,width,height,direction,activation){
	//话框创造器对象的一个构造函数：创建一个色彩平平面
	var colorExampleBgColor = new Array;
	colorExampleBgColor[0] = defultColor;
	colorExampleBgColor[1] = width;
	colorExampleBgColor[2] = height;
	colorExampleBgColor[3]= direction;
	var colorExampleBgColorActivtion = new Array;
	if(activation){
		colorExampleBgColorActivtion["activeDown"] = activation["activeDown"];
		colorExampleBgColorActivtion["activeOver"] = activation["activeOver"];
		colorExampleBgColorActivtion["activeDrag"] = activation["activeDrag"];
		colorExampleBgColorActivtion["activeUp"] = activation["activeUp"];
		}
	var colorExample = new dialog.frame(name,[],[],colorExampleBgColor,colorExampleBgColorActivtion);
	
	colorExample.upData = function(newColor){
		this.changeBgColor(newColor);
		}
		
	return colorExample;
	}
	
	
dialog.basicCreator.prototype.createAColorLine = function(name,defultColor,width,height,direction,edge){
	//话框创造器对象的一个构造函数：创建一个线性色彩条带，
	var touchEdge = edge == undefined ? 20 : edge;
	var halfEdge = touchEdge/2;
	var activation = [];
	activation["activeDown"] = activation["activeDrag"] = function (Param){
		var newX = Param[0];
			if(newX>halfEdge+width){newX = halfEdge+width;}
					else if (newX < halfEdge){newX = halfEdge;}
		var colorNum = parseInt(6*(newX-halfEdge)/(this.width-touchEdge));
		var overageX = newX-halfEdge-colorNum*(this.width-touchEdge)/6;
		switch(colorNum){
			case 0:
				var newColor = [1,0,0,1];
				newColor[2] = 6*overageX/(this.width-touchEdge);
				break;
			case 1:
				var newColor = [1,0,1,1];
				newColor[0] = 1-6*overageX/(this.width-touchEdge);
				break;
			case 2:
				var newColor = [0,0,1,1];
				newColor[1] = 6*overageX/(this.width-touchEdge);
				break;
			case 3:
				var newColor = [0,1,1,1];
				newColor[2] = 1-6*overageX/(this.width-touchEdge);
				break;
			case 4:
				var newColor = [0,1,0,1];
				newColor[0] = 6*overageX/(this.width-touchEdge);
				break;
			case 5:
				var newColor = [1,1,0,1];
				newColor[1] = 1-6*overageX/(this.width-touchEdge);
				break;
			case 6:
				var newColor = [1,0,0,1];
				break;
			}
		var topParent = dialog.findTheTopParent(this);
		this.getChildByName("colorLine_cursor").moveTo([Math.round(newX-5),0]);
		topParent.getChildByName("purePlan_color").changeBgColor(newColor);
		topParent.getChildByName("purePlan").flashDataToTop();
		
		}
	
	var colorLineTouch = this.createAColorPlan(name,
										   [0,0,0,0],
										   width+touchEdge,height+touchEdge,[],activation);
	var colorLineBg = this.createAColorPlan("colorLine_color",
											 [[1,0,0,1],
											  [1,0,1,1],
											  [0,0,1,1],
											  [0,1,1,1],
											  [0,1,0,1],
											  [1,1,0,1],
											  [1,0,0,1]],
											 width,height,
											 direction);

	var colorLineArray =  [0,0,colorLineTouch,[],[],[],[],
								[halfEdge,halfEdge,colorLineBg],
								[0,0,"colorLine_cursor",[],[textures["setColor_line_cursor"]],[],[]]
						   ];
	
	var colorLine = this.converArrayToDialog(colorLineArray);
	
	colorLine.upData = function(newColor){
		var maxNum;
		var minNum;
		maxNum = newColor[2]>newColor[1] ? 2 : 1;
		maxNum = newColor[maxNum]>newColor[0] ? maxNum : 0;
		switch(maxNum){
			case 0:
			minNum = newColor[1]>newColor[2] ? 2 : 1;
			break;
			case 1:
			minNum = newColor[0]>newColor[2] ? 2 : 0;
			break;
			default:
			minNum = newColor[1]>newColor[0] ? 0 : 1;
			break;
			}
		for(n=0;n < 3;n++){
			if(n!=maxNum && n!=minNum){
				var midNum = n;
				}
			}
		if(newColor[maxNum] != newColor[minNum]){
			newColor[midNum] = (newColor[midNum]-newColor[minNum])/(newColor[maxNum]-newColor[minNum]);
			newColor[minNum] = 0;
			newColor[maxNum] = 1;
			}
			else{
				newColor[maxNum] = 1;
				newColor[midNum] = 0;
				newColor[minNum] = 0;
				}
		var deltaX = halfEdge;
		switch(maxNum){
			case 0:
				switch(midNum){
					case 2:
						deltaX = (this.width-touchEdge)*newColor[2]/6+halfEdge;
						break;
					case 1:
						deltaX = (this.width-touchEdge)*(6-newColor[1])/6+halfEdge;
						break;
					}
				break;
			case 1:
				switch(midNum){
					case 2:
						deltaX = (this.width-touchEdge)*(4-newColor[2])/6+halfEdge;
						break;
					case 0:
						deltaX = (this.width-touchEdge)*(4+newColor[0])/6+halfEdge;
						break;
					default:
						deltaX = (this.width-touchEdge)*5/6+halfEdge;
						break;
					}
				break;
			case 2:
				switch(midNum){
					case 0:
						deltaX = (this.width-touchEdge)*(2-newColor[0])/6+halfEdge;
						break;
					case 1:
						deltaX = (this.width-touchEdge)*(2+newColor[1])/6+halfEdge;
						break;
					default:
						deltaX = (this.width-touchEdge)/6+halfEdge;
						break;
					}
				break;
			}
		this.getChildByName("colorLine_cursor").moveTo([Math.round(deltaX-5),0]);
		}
	colorLine.upData(defultColor);
	return colorLine;
	}
	
	
dialog.basicCreator.prototype.createAPureColorPlan = function(name,defultColor,width,height,edge){
	//话框创造器对象的一个构造函数：创建一个“纯度亮度平面”，包含一个.value值，保存当前光标指示的颜色。
	var touchEdge = edge == undefined ? 20 : edge;
	var halfEdge = touchEdge/2;
	var blackCover = this.createAColorPlan("purePlan_black",
										   [[0, 0, 0, 1], [0, 0, 0, 0]],
										   width,height,"downToUp"
										   );
	var whiteCover = this.createAColorPlan("purePlan_white",
										   [[1, 1, 1, 1], [1, 1, 1, 0]],
										   width,height,"leftToRight"
										   );
	var colorCoverActivation = [];
		colorCoverActivation["activeDrag"] =
		colorCoverActivation["activeDown"] = function(Param){
			var newX = Param[0];
			var newY = Param[1];
			if(newX>halfEdge+width){newX = halfEdge+width;}
					else if (newX < halfEdge){newX = halfEdge;}
			if(newY>halfEdge+height){newY = halfEdge+height;}
					else if (newY < halfEdge){newY = halfEdge;}
					
			var cursor = this.getChildByName("purePlan_cursor");
			cursor.moveTo([newX-cursor.width/2,newY-cursor.height/2]);
			this.flashDataToTop();
			}
	var touchCover = this.createAColorPlan(name,
										   [0, 0, 0, 0.5], 
										   width+touchEdge,height+touchEdge,[],colorCoverActivation
										   );
	var colorCover = this.createAColorPlan("purePlan_color",
										   defultColor,
										   width,height);
	
	var purePlanArray = [0,0,touchCover,[],[],[],[],
							[halfEdge,halfEdge,colorCover],
							[halfEdge,halfEdge,whiteCover],
							[halfEdge,halfEdge,blackCover],
							[0,0,"purePlan_cursor",[],[textures["setColor_pure_cursor"]],[],[]]
						 ];
	var purePlan = this.converArrayToDialog(purePlanArray);
	purePlan.flashDataToTop = function (){
		var cursor = this.getChildByName("purePlan_cursor");
			var x = cursor.x+cursor.width/2;
			var y = cursor.y+cursor.height/2;
			var purePlan_color = this.getChildByName("purePlan_color");
			var pureColor = [];
			pureColor[0] = purePlan_color.bgColor[0];
			pureColor[1] = purePlan_color.bgColor[1];
			pureColor[2] = purePlan_color.bgColor[2];
			var maxNum;
			var minNum;
			maxNum = pureColor[2]>pureColor[1] ? 2 : 1;
			maxNum = pureColor[maxNum]>pureColor[0] ? maxNum : 0;
			switch(maxNum){
				case 0:
				minNum = pureColor[1]>pureColor[2] ? 2 : 1;
				break;
				case 1:
				minNum = pureColor[0]>pureColor[2] ? 2 : 0;
				break;
				default:
				minNum = pureColor[1]>pureColor[0] ? 0 : 1;
				break;
				}
			for(n=0;n < 3;n++){
				if(n!=maxNum && n!=minNum){
					var midNum = n;
					}
				}
			pureColor[maxNum] = (height-y+halfEdge)/height;
			pureColor[midNum] = pureColor[midNum]*(height-y+halfEdge)/height;
			pureColor[midNum] += (width-x+halfEdge)/width*(pureColor[maxNum]-pureColor[midNum]);
			pureColor[minNum] = pureColor[minNum]*(height-y+halfEdge)/height;
			pureColor[minNum] += (width-x+halfEdge)/width*(pureColor[maxNum]-pureColor[minNum]);
			
			this.value = pureColor;
			var topParent = dialog.findTheTopParent(this);
			topParent.flashDataBy(this);
		}
	
	
	purePlan.upData = function(newColor){
		var maxNum;
		var minNum;
		maxNum = newColor[2]>newColor[1] ? 2 : 1;
		maxNum = newColor[maxNum]>newColor[0] ? maxNum : 0;
		switch(maxNum){
			case 0:
			minNum = newColor[1]>newColor[2] ? 2 : 1;
			break;
			case 1:
			minNum = newColor[0]>newColor[2] ? 2 : 0;
			break;
			default:
			minNum = newColor[1]>newColor[0] ? 0 : 1;
			break;
			}
		for(n=0;n < 3;n++){
			if(n!=maxNum && n!=minNum){
				var midNum = n;
				}
			}
		var deltaX = newColor[maxNum] == 0 ?
					 0 : 
					 Math.round((this.width-touchEdge)*newColor[minNum]/newColor[maxNum])+halfEdge;
		var deltaY = Math.round((this.height-touchEdge)*newColor[maxNum])+halfEdge;
		var cursor = this.getChildByName("purePlan_cursor");
		cursor.moveTo([this.width-deltaX-cursor.width/2,this.height-deltaY-cursor.height/2]);
		
		if(newColor[maxNum] != newColor[minNum]){
			newColor[midNum] = (newColor[midNum]-newColor[minNum])/(newColor[maxNum]-newColor[minNum]);
			newColor[minNum] = 0;
			newColor[maxNum] = 1;
			}
			else{
				newColor[maxNum] = 1;
				newColor[midNum] = 0;
				newColor[minNum] = 0;
				}
		this.getChildByName("purePlan_color").changeBgColor(newColor);
		}
	purePlan.value = defultColor;
	purePlan.upData(defultColor);
	return purePlan;
	}
	 

dialog.basicCreator.prototype.createADragBar = function(name,dragText,pointN,wordShift,
														defultValue,leftX,rightX,numShift,
														minValue,maxValue){
	//话框创造器对象的一个构造函数：创建一个拖动条，包含一个.value值，保存当前光标指示的幅值。
	var startX=leftX,endX=rightX;
	//------------------------------------
	var displayValue = defultValue.toFixed(pointN);
	
	var dragBar_text = [];
		dragBar_text[0] = String(displayValue);
		dragBar_text[1] = numShift;
		dragBar_text[2] = 10;
//	var dragBar_image = [];
//		dragBar_image[0] = textures["dragBar_line"];
		
	var dragBar_fun = [];
	
		dragBar_fun["activeDrag"] = dragBar_fun["activeDown"] = function(Param){
			var downX = Param[0];
				if(downX>endX){downX = endX;}
					else if (downX < startX){downX = startX;}
			var value = (downX-startX)/(endX-startX);
				value = value*(maxValue-minValue)+minValue;
				value = parseFloat(value.toFixed(pointN));
			this.value = value;
			this.changeText([String(value.toFixed(pointN))]);
			
			this.getChildByName("dragFrame").moveTo([downX-5,0]);
			
			var topParent = dialog.findTheTopParent(this);
			topParent.flashDataBy(this);
			}
	
	//--------------------------------
	var dragFrameX;
		dragFrameX = Math.round(startX+(endX-startX)*(defultValue-minValue)/(maxValue-minValue));
	var dragFrame_image = [];
		dragFrame_image[0] = textures["setColor_rgb_cursor"];
	//----------------------------------

	var dragBarArray = [0,0,name,dragBar_text,[],[,320,20],dragBar_fun,
							[dragFrameX-5,0,"dragFrame",[],dragFrame_image,[],[]],
							[wordShift,8,"dragText",[dragText],[],[],[]]
						];
	var dragBarData;
		dragBarData = this.converArrayToDialog(dragBarArray);
		
		dragBarData.value = displayValue;
		
		dragBarData.upData = function(newValue){
			var value = (newValue-minValue)/(maxValue-minValue);
			var downX = Math.round(startX+value*(endX-startX));
			this.getChildByName("dragFrame").moveTo([downX-5,0]);
			
			value = value*(maxValue-minValue)+minValue;
			value = parseFloat(value.toFixed(pointN));
			this.value = value;
			
			this.changeText([String(value)]);
			}
	return dragBarData;
	}
	

	
dialog.create_SetColor = function(dialogCreator,defultColor,certainAction,cancelAction){
//创建颜色选单的主程序，传递进来一个话框构造器。用这个话框构造器来创建一些对话框
//设定颜色选单的背景颜色
//---------------------------------------
//创建三个拖动条
	var dragBar = new Array;

	dragBar[0] = dialogCreator.createADragBar("redBar","红",0,5,
											  defultColor[0]*255,60,315,25,
											  0,255);
	dragBar[1] = dialogCreator.createADragBar("greenBar","绿",0,5,
											  defultColor[1]*255,60,315,25,
											  0,255);
	dragBar[2] = dialogCreator.createADragBar("blueBar","蓝",0,5,
											  defultColor[2]*255,60,315,25,
											  0,255);
	dragBar[3] = dialogCreator.createADragBar("alphaBar","透明度",1,5,
											  defultColor[3],90,315,50,
											  0.1,1);
//--------------------------------------------------
//创建一个用于显示当前选择色彩的平面
	var colorPlan = dialogCreator.createAColorPlan("colorShow",
													 defultColor,
													 75,
													 75);
//------------------------------------------------------------
//创建一个色相条
	var colorLine = dialogCreator.createAColorLine("colorLine",
													 [defultColor[0],
													  defultColor[1],
													  defultColor[2],
													  1],
													 192,
													 20,
													 "leftToRight");
//---------------------------------------------------------------------------------
//一个纯度亮度选取平面
	var pureColorPlan = dialogCreator.createAPureColorPlan("purePlan",
															 [defultColor[0],
															  defultColor[1],
															  defultColor[2],
															  1],
															 192,70,0);
	
//-------------------------------------------------------------------------------------
//创建一个确定按钮
	var certainButton = dialogCreator.createAButton("certainButton",["确定"],[],[,75,20],
													textures["button_ok_white"],textures["button_ok_blue"]);
//-------------------------------------------------------------------------------------
//创建一个取消按钮
	var cencelButton = dialogCreator.createAButton("cancelButton",["取消"],[],[,75,20],
													textures["button_closeX_white"],textures["button_closeX_red"]);
//-----------------------------------------------------------------------------------
	var dragFunction = [];
	dragFunction["activeDrag"] = function(Param){
		
		if(!mouseCursorStatus){
			mouseAmong = 1;
			mouseCursorStatus = mouseCursor;
			mouseCursor = "MOVE";
			}
	
		var top = dialog.findTheTopParent(this);
			var upOne = this;
			var downX = eyeMoveDelta[2],downY = eyeMoveDelta[3]
			if(downX>cubeClient.width){downX = cubeClient.width;}
					else if (downX < 0){downX = 0;}
			if(downY>cubeClient.height){downY = cubeClient.height;}
					else if (downY < 0){downY = 0;}
			for(;
				upOne.parent;
				upOne = upOne.parent){
										downX = downX-upOne.x;
										downY = downY-upOne.y;
										}
		top.moveTo([downX-Param[2],downY-Param[3]]);
		}
	dragFunction["activeDown"] = function(Param){
		//mouseCursor = "MOVE";
		}
	dragFunction["activeLeave"] = function(Param){
		if(mouseCursorStatus&&mouseAmong ==1 ){
			mouseCursor = mouseCursorStatus;
			mouseCursorStatus=null;
			}
		}
		
//-----------------------------------------------------------------------------------
	var setDefultColor_function = [];
		setDefultColor_function["activeOver"] = function(){
			//cubeClient.cursor = cubeO3d.Cursor.DEFAULT;
			}

	var setDefultColor_Array = [-720,500,"setDefultColor",[],[],[,610,145],setDefultColor_function,
									[-5,-5,"setDefultColor_frameLine",[],[textures["setColor_cover"]],[],[]],
									[0,0,"dragTitle",[],[],[,610,20],dragFunction,
										[0,0,"dragTitle_bg",["调色板",5,5],[textures["setColor_title"]],[],[]]
										],
									[0,35,dragBar[0]],
									[0,55,dragBar[1]],
									[0,75,dragBar[2]],
									[0,115,dragBar[3]],
									[325,20,colorPlan],
									[411,30,pureColorPlan],
									[401,105,colorLine],
									[325,95,certainButton],
									[325,125,cencelButton]
						  		];
	
	var topDialog =  dialogCreator.converArrayToDialog(setDefultColor_Array);
		topDialog.red = defultColor[0];
		topDialog.green = defultColor[1];
		topDialog.blue = defultColor[2];
		topDialog.alpha = defultColor[3];
		
		topDialog.certainAction = certainAction ? certainAction : function(){};
		topDialog.cancelAction = cancelAction ? cancelAction : function(){};

	topDialog.flashDataBy = function(trueDialog){
		//最顶层的对话框拥有的一个响应函数，下面的子集会执行这个函数，并返回他们自己，这个函数会判断是
		//哪个子集执行了响应，并对不同的响应作出的处理
		switch (trueDialog.name){
			case "redBar":
				this.red = this.getChildByName("redBar").value/255;
				this.getChildByName("purePlan").upData([this.red,this.green,this.blue,1]);
				this.getChildByName("colorLine").upData([this.red,this.green,this.blue,1]);
				break;
			case "greenBar":
				this.green = this.getChildByName("greenBar").value/255;
				this.getChildByName("purePlan").upData([this.red,this.green,this.blue,1]);
				this.getChildByName("colorLine").upData([this.red,this.green,this.blue,1]);
				break;
			case "blueBar":
				this.blue = this.getChildByName("blueBar").value/255;
				this.getChildByName("purePlan").upData([this.red,this.green,this.blue,1]);
				this.getChildByName("colorLine").upData([this.red,this.green,this.blue,1]);
				break;
			case "alphaBar":
				this.alpha = this.getChildByName("alphaBar").value;
				break;
			case "purePlan":
				var flashColor = this.getChildByName("purePlan").value;
				this.red = flashColor[0];
				this.green = flashColor[1];
				this.blue = flashColor[2];
				this.getChildByName("redBar").upData(this.red*255);
				this.getChildByName("greenBar").upData(this.green*255);
				this.getChildByName("blueBar").upData(this.blue*255);
				break;
			case "certainButton":
			//把确定按钮按下时执行的函数写在这里就可以进行交互，比如：this.red 就会得到当前设置颜色框
			//中红色的设置数值。
/*				this.changeObject.red = this.red;
				this.changeObject.green = this.green;
				this.changeObject.blue = this.blue;
				this.changeObject.alpha = this.alpha;
*/				this.certainAction(this.red,this.green,this.blue,this.alpha);
					this.delActiveNow();
					//dialog.moveDialogTo(this,-720,this.y);
					dialog.alphaShow(this,1,0,10);
				break;
			case "cancelButton":
			//取消按钮的执行函数
/*				this.red = this.changeObject.red;
				this.green = this.changeObject.green;
				this.blue = this.changeObject.blue;
				this.alpha = this.changeObject.alpha;
*/				this.cancelAction(this.red,this.green,this.blue,this.alpha);
					this.delActiveNow();
					//dialog.moveDialogTo(this,-720,this.y);
					dialog.alphaShow(this,1,0,10);
				break;
			}
		this.getChildByName("colorShow").upData([this.red,this.green,this.blue,this.alpha]);
		}
	topDialog.upData = function(r,g,b,alpha){
				this.getChildByName("purePlan").upData([r,g,b,1]);
				this.getChildByName("colorLine").upData([r,g,b,1]);
				this.getChildByName("redBar").upData(r*255);
				this.getChildByName("greenBar").upData(g*255);
				this.getChildByName("blueBar").upData(b*255);
				this.getChildByName("alphaBar").upData(alpha);
				this.getChildByName("colorShow").upData([r,g,b,alpha]);
				this.red = r;
				this.green = g;
				this.blue = b;
				this.alpha = alpha;
		}
		
	topDialog.show = function(defultColor,certainAction,cancelAction){
		this.upData(defultColor[0],defultColor[1],defultColor[2],defultColor[3]);
		this.certainAction = certainAction ? certainAction : function(){};
		this.cancelAction = cancelAction ? cancelAction : function(){};
		this.moveTo([100,eyeMoveDelta[3]-80]);
		dialog.alphaShow(this,0,1,10);
		}
	
	return topDialog;
	}



//每一组菜单能占用300的Z值，组里的每个对话框能占用30，也就是最多一组能有10个对话框。按对话框系统占用0~3000的Z值来看~最多能够有10组对话框系统。
dialog.frame.prototype.addNewActiveNow = function(){
	frameActiveNow[frameActiveNow.length] = [];
	frameActiveNow[frameActiveNow.length-1].push(this);
	this.changeZ([(frameActiveNow.length-1)*300]);
	}
	
dialog.frame.prototype.addActiveNowBy = function(parentFrame){
	var nActive;
	for(var n=0;n < frameActiveNow.length;n++){
		if(frameActiveNow[n][frameActiveNow[n].length-1]==parentFrame){
			nActive = n;
			}
		}
	if(nActive != undefined){
		frameActiveNow[nActive].push(this);
		this.changeZ([(frameActiveNow[nActive].length-1)*30+nActive*300]);
		}
	}

dialog.frame.prototype.delActiveNow = function(){
	var nActive;
	for(var n=0;n < frameActiveNow.length;n++){
		if(frameActiveNow[n][frameActiveNow[n].length-1]==this){
			nActive = n;
			}
		}
	if(nActive != undefined){
		frameActiveNow[nActive].pop();
		if(!frameActiveNow[nActive][0]){
			frameActiveNow.splice(nActive,1);
			}
		for(var n=0;n < frameActiveNow.length;n++){
			for(var i=0;i < frameActiveNow[n].length;i++){
				frameActiveNow[n][i].changeZ([n*300+i*30]);
				}
			}
		}
	}
	
dialog.frame.prototype.checkActiveNum = function(){
	var nActive;
	for(var n=0;n < frameActiveNow.length;n++){
		if(frameActiveNow[n][frameActiveNow[n].length-1]==this){
			nActive = n;
			}
		}
	return nActive;
	}
